<template>
  <f-layout class="page-layout page-table">
    <f-edit-table-sub ref="table" v-bind="tableConfig">
      <template #toolbar_left>
        <f-dictionary
          type="radio-button"
          v-model:value="status"
          :showAllOption="true"
          code="inboundStatus">
        </f-dictionary>
      </template>
      <template #toolbarRight="checkedRows">
        <f-button
          class="mr12"
          :disabled="disableDel(checkedRows)"
          @click="batchSubmit(checkedRows)">
          批量提交
        </f-button>

        <f-button
          class="mr12"
          :disabled="disableSubmit(checkedRows)"
          @click="batchDel(checkedRows)">
          批量删除
        </f-button>
        <f-dropdown-button class="mr12">
          新增
          <template #overlay>
            <f-menu @click="handleMenuClick">
              <f-menu-item v-for="item in items" :key="item.value">
                {{ item.label }}
              </f-menu-item>
            </f-menu>
          </template>
        </f-dropdown-button>
      </template>
    </f-edit-table-sub>
  </f-layout>
</template>
<script setup lang="ts">
import { useMethods } from './methods';
import { ref, watch } from 'vue';
import { useRouter } from 'vue-router';

const status = ref(null);
const { tableConfig, table, batchSubmit, disableDel, disableSubmit, batchDel } = useMethods(status);
const items = ref([{ label: 'x', value: '1' }]);
const router = useRouter();

watch(status, () => {
  table.value.refresh();
});
function handleMenuClick(e) {
  router.push({ path: '/stock-entry-add-index', query: { bizType: e.key } });
}
</script>
